/* 
 * Lydbaer Extensions for TTBlue
 * Creates a wrapper for TTAudioObjects that can be used to build an audio processing graph.
 * Copyright © 2008, Timothy Place
 * 
 * License: This code is licensed under the terms of the GNU LGPL
 * http://www.gnu.org/licenses/lgpl.html 
 */

#include "multicoreSource.h"
#define thisTTClass MCoreSource


MCoreSource::MCoreSource(TTValue& arguments)
: TTAudioObject(TT("multicore.source"), arguments), buffers(NULL)
{
	TTAudioSignalPtr	buffer = NULL;
	
	TTObjectInstantiate(kTTSym_audiosignal, &buffer, arguments);
	TTObjectInstantiate(kTTSym_audiosignalarray, (TTObjectPtr*)&buffers, arguments);
	
	buffers->setSignal(0, buffer);
	setProcessMethod(processAudio);
}


MCoreSource::~MCoreSource()
{
	TTAudioSignalPtr	buffer = &(buffers->getSignal(0));
	
	TTObjectRelease(&buffer);
	TTObjectRelease((TTObjectPtr*)&buffers);
}


TTErr MCoreSource::processAudio(TTAudioSignalArrayPtr inputs, TTAudioSignalArrayPtr outputs)
{
	TTAudioSignal&	out = outputs->getSignal(0);
	TTAudioSignal&	buffer = buffers->getSignal(0);
	
	return TTAudioSignal::copy(buffer, out);
}
